package com.huawei.appgallery.foundation.ui.framework.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;
import o.dky.a;
import o.dky.o;
import o.Logger;

public class MaskImageView extends ImageView {
    private Context ˊ;
    private int ˋ = 0;
    protected int ˎ = 0;
    protected Drawable ॱ;

    public MaskImageView(Context context) {
        super(context);
        this.ˊ = context;
        ˏ(null);
    }

    public MaskImageView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.ˊ = context;
        ˏ(attributeSet);
    }

    public MaskImageView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.ˊ = context;
        ˏ(attributeSet);
    }

    public void setCornerType(int i) {
        this.ˋ = i;
    }

    public int ॱ(int i) {
        this.ˎ = i;
        return i;
    }

    void ˏ(AttributeSet attributeSet) {
        setClickable(true);
        if (attributeSet != null) {
            TypedArray obtainStyledAttributes = this.ˊ.obtainStyledAttributes(attributeSet, o.ʼʻ);
            try {
                this.ˎ = obtainStyledAttributes.getInt(o.ʿˊ, 0);
                this.ˋ = obtainStyledAttributes.getInt(o.ʾᐝ, 0);
            } catch (Exception e) {
                Logger.e("MaskImageView", e.toString());
            } finally {
                obtainStyledAttributes.recycle();
            }
        }
    }

    public void setmRoundKind(int i) {
        this.ˎ = i;
    }

    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        if (!isInEditMode()) {
            ˎ();
        }
    }

    protected void ˎ() {
        if (1 == this.ˎ) {
            if (this.ˋ == 0) {
                this.ॱ = getResources().getDrawable(a.ʾ);
                return;
            } else if (this.ˋ == 1) {
                this.ॱ = getResources().getDrawable(a.ʽॱ);
                return;
            } else if (this.ˋ == 2) {
                this.ॱ = getResources().getDrawable(a.ʼॱ);
                return;
            } else if (this.ˋ == 3) {
                this.ॱ = getResources().getDrawable(a.ʿ);
                return;
            } else if (this.ˋ == 4) {
                this.ॱ = getResources().getDrawable(a.ˊˋ);
                return;
            }
        }
        this.ॱ = getResources().getDrawable(a.ˋˊ);
    }

    protected void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(canvas);
        if (this.ॱ != null && !isInEditMode()) {
            this.ॱ.setBounds(0, 0, getWidth(), getHeight());
            this.ॱ.draw(canvas);
        }
    }

    protected void drawableStateChanged() {
        if (this.ॱ != null) {
            this.ॱ.setState(getDrawableState());
            invalidate();
        }
        super.drawableStateChanged();
    }

    public void ˊ(int i, int i2) {
        setCornerType(i);
        setmRoundKind(i2);
    }
}
